import { cloneDeep } from 'lodash-es';
import { ITEM_DATA } from '../../data/item';
import {
  EQUIP_SLOT_DESC_MAP,
  ITEM_RARITY_DESC_MAP,
  ITEM_TYPE_DESC_MAP,
  type EquipSlot,
  type ItemRarity,
  type ItemType,
} from '../../data/item/type';

export class ItemReader {
  /** 根据 id 获取物品配置 */
  static getConfig(id: string) {
    const item = ITEM_DATA.find((item) => item.id === id);
    return cloneDeep(item) || null;
  }

  static getItemRarityName(rarity: ItemRarity) {
    return ITEM_RARITY_DESC_MAP[rarity];
  }

  static getEquipSlotName(key: EquipSlot) {
    return EQUIP_SLOT_DESC_MAP[key];
  }

  static getItemTypeName(type: ItemType) {
    return ITEM_TYPE_DESC_MAP[type];
  }
}
